package huachenxing.mimi520.option.widgets
{
	import com.cambright.stack.components.layout.Element;
	import com.cambright.stack.components.layout.Fill;
	
	import flash.geom.Rectangle;
	
	import huachenxing.mimi520.option.commands.CloseAccountWindowCommand;
	import huachenxing.mimi520.option.models.AccountModel;
	import huachenxing.mimi520.skin.Input;
	import huachenxing.mimi520.skin.Text;
	
	public class AccountWindowWidget extends WindowWidget
	{
		private var _usernameInput:Input;
		private var _passwordInput:Input;
		
		override protected function invoke():void
		{
			super.invoke();
			
			var usernameLabel:Text = new Text("用户名");
			usernameLabel.color = 0x707c89;
			
			_usernameInput = new Input();
			_usernameInput.textColor = 0x707c89;
			
			var passwordLabel:Text = new Text("密码");
			passwordLabel.color = 0x707c89;
			
			_passwordInput = new Input();
			_passwordInput.textColor = 0x707c89;
			
			addElement(new Element(usernameLabel));
			addElement(new Element(_usernameInput, 1, Fill.HORIZONTAL));
			addElement(new Element(passwordLabel, 2));
			addElement(new Element(_passwordInput, 3, Fill.HORIZONTAL));
		}
		
		override protected function get rect():Rectangle
		{
			return new Rectangle(Number.MIN_VALUE, Number.MIN_VALUE, 300, 200);
		}
		
		override protected function get title():String
		{
			return "账号设置";
		}
		
		override protected function get close():Class
		{
			return CloseAccountWindowCommand;
		}
		
		override protected function enable():void
		{
			_usernameInput.text = AccountModel.username;
			_passwordInput.text = AccountModel.password;
			super.enable();
		}
		
		override protected function disable():void
		{
			super.disable();
			AccountModel.username = _usernameInput.text;
			AccountModel.password = _passwordInput.text;
		}
	}
}